/**
 * @author: zouye<yzyngz@foxmail.com>
 * @date: 2022-01-08 18:01:15
 * @copyright: zouye<yzyngz@foxmail.com>
 */
package com.yeah.voice.recognition.common;

/**
 * 通用接口返回值封装
 */
public class Result {
	// 状态，OK、ERROR
	private String status;
	
	// 错误码
	private Integer code;
	
	// 成功、失败信息
	private String message;
	
	// 数据
	private Object data;

	/**
	 * @return the status
	 */
	public String getStatus() {
		return status;
	}

	/**
	 * @param status the status to set
	 */
	public Result setStatus(String status) {
		this.status = status;
		return this;
	}

	/**
	 * @return the code
	 */
	public Integer getCode() {
		return code;
	}

	/**
	 * @param code the code to set
	 */
	public Result setCode(Integer code) {
		this.code = code;
		return this;
	}

	/**
	 * @return the message
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * @param message the message to set
	 */
	public Result setMessage(String message) {
		this.message = message;
		return this;
	}

	/**
	 * @return the data
	 */
	public Object getData() {
		return data;
	}

	/**
	 * @param data the data to set
	 */
	public Result setData(Object data) {
		this.data = data;
		return this;
	}
	
	public Result() {}
	
	public static Result ok() {
		return new Result().setStatus("OK").setMessage("操作成功");
	}
	
	public static Result ok(Object data) {
		return ok().setData(data);
	}
	
	public static Result fail(Integer code, String message) {
		return new Result().setCode(code).setStatus("ERROR").setMessage("操作失败，" + message);
	}
}
